﻿(function($){
    DepartInfo = function(data){
        return {
            fill:function(){
                var departmodel = $(".departmodel");
                console.log(departmodel);
                console.log(data);
                var table = data.Table;
                for(var i=0;i<table.length;i++){
                    var departId = table[i].depart_id;
                    var departName = table[i].DepartName;
                    var t4total = table[i].FieldTotal;
                    var t4num = table[i].FieldNum;
                    var t4percent = Math.round(~~t4num*100/~~t4total);
                    
                    var t5total = table[i].t5total;
                    var t5num = table[i].t5num;
                    var t5percent = Math.round(~~t5num*100/~~t5total); 
                   
                    var onerow = departmodel.clone();
                    onerow.attr("departId", departId);
                    onerow.children().eq(1).html(departName);//部门名称
                    //onerow.children().eq(3).find("a").attr("href","../ZP/SelfExaminationDetail.aspx?type=1&DepartID={0}".format(departId));
                    //onerow.children().eq(5).find("a").attr("href","../NRBZ/NRFBDetail.aspx?type=2&DepartID={0}".format(departId));
                    onerow.children().eq(3).find("a").html("完成度：{0}/{1}({2}%)".format(t4num,t4total,t4percent)).attr("href","../ZP/SelfExaminationDetail.aspx?type=1&DepartID={0}".format(departId));
                    onerow.children().eq(5).find("a").html("完成度：{0}/{1}({2}%)".format(t5num,t5total,t5percent)).attr("href","../NRBZ/NRFBDetail.aspx?type=2&DepartID={0}".format(departId));;
                    var detailPath = "ExpertGradeDetail";
                    if("0"==$("#ex_is_expert").val()){
                        detailPath = "VolunteerGradeDetail";
                    }
                    onerow.children().eq(9).find("a").attr("href","{0}.aspx?departName={1}&departId={2}".format(detailPath, departName,departId));
                    onerow.removeClass("departmodel");
                    onerow.addClass("departmodel1");
                    if($(".departmodel1").size() > 0){
                        $(".departmodel1").last().after(onerow);
                    } else {
                        $(".departmodel").last().after(onerow)
                    }
                }
            }
        }     
    }

})($);